package com.phaeton.beemeup.entity;

import org.andengine.engine.handler.IUpdateHandler;
import org.andengine.entity.primitive.Rectangle;
import org.andengine.util.color.Color;

import android.util.Log;

import com.phaeton.beemeup.GameManager;

public class FightProgress extends Rectangle {
	private Rectangle progressRect;
	private float progress;
	
	public FightProgress(GameManager pGameManager, final float pX, final float pY, float pProgress) {
		super(pX, pY, 120, 20, pGameManager.getActivity().getVertexBufferObjectManager());
		
		progressRect = new Rectangle(0, 0, 120, 20, pGameManager.getActivity().getVertexBufferObjectManager());
		
		progress = pProgress;
		
		this.setColor(Color.YELLOW);
		progressRect.setColor(Color.RED);
		this.attachChild(progressRect);
		
		this.registerUpdateHandler(new IUpdateHandler(){

			@Override
			public void onUpdate(float pSecondsElapsed) {
				progressRect.setWidth(120 * progress);
			}

			@Override
			public void reset() {
				// TODO Auto-generated method stub
				
			}
			
		});
	}	
	
	public void setProgress(float f){
		Log.e("Progress", "progress set to "+progress);
		progress = f;
	}
}
